<?php

namespace App\Models\Car;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
// 按揭记录
class MortgageLog extends Model
{
    use HasFactory;
    protected $guarded=[];
//    protected $fillable = ['common_user','status','is_show','car_id','avatar','openid'];
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
//    public function getOutsetPhotoAttribute($value)
//    {
//        return json_decode($value,true);
//    }
//    //return_photo
//    public function setReturnPhotoAttribute($value)
//    {
//        $this->attributes['return_photo'] = json_encode($value);
//    }
    public function setCarsAttribute($value)
    {
        $this->attributes['cars'] = json_encode($value);
    }
    public function getCarsAttribute($key)
    {
        if($key){
            return json_decode($key,true);
        }else{
            return '';
        }
    }

    public function list(){
        return $this->hasMany(MortgageDetail::class,'order_sn','order_sn');
    }
}
